$(function(){
	$('.loginuser').hover(
		function(){
			$('.loginuser .subnav').slideDown();
			$(this).addClass('navhover');
		},function(){
			$('.loginuser .subnav').slideUp();
			$(this).removeClass('navhover');
		}
	);
	$('.like').hover(function(){
		$('.dolike').html('顶一下');
	},function(){
		$('.dolike').html('我喜欢');
	});
});
function dofollow(uid){
$.post('/do/follow',{uid:uid},function(msg){
	$.dialog({
		title:'关注',
		content:msg.info,
		time:1000
	});
},'json');
}
function docomment(aid){
	var message = $('.cmessage').val();
	if(message==''){
		$.dialog({
			title:'警告',
			content:'评论内容不能空',
			time:1000
		});
		return false;
	}
	$.post('/do/comment',{aid:aid,message:message},function(msg){
		if(msg.status==1){
			$('#commentlist').prepend('<li class="newcomment"><div class="cu"><img src="'+msg.data.avatar+'" /></div><div class="ci"><div class="cc"><a href="http://user.sanwen8.cn/'+msg.data.uid+'/">'+msg.data.username+'</a>：'+msg.data.message+'</div><div class="cd"><a href="javascript:void(0)" onclick="delcomment('+msg.data.cid+');">删除</a>刚刚</div></div></li>').slideDown('slow');
		}
		$.dialog({
			title:'评论结果',
			content:msg.info+'，1s后自动关闭！',
			time:1000
		});
	});
}
function dolike(aid){
$.post('/do/ilike',{aid:aid},function(msg){
	if(msg.status==1){
		$('.likenum').html(msg.data);
	}
	$.dialog({
		title:'推荐结果',
		content:msg.info+'，1s自动关闭！',
		time:1000
	});
},'json');
}
function reply(cid){
$.dialog({
	title:'回复评论',
	content:'<textarea name="replymessage" style="padding:8px; border:1px solid #ccc; width:300px; height:60px; overflow:auto;" id="replymessage"></textarea>',
	okValue:'回复',
	ok:function(){
		var message = $("#replymessage").val();
		if(message==''){
			alert('回复内容不能空');
			return false;
		}
		$.post('/do/reply',{cid:cid,message:message},function(msg){
			if(msg.status==1){
				$('#c_'+cid).after('<li id="c_'+msg.data.cid+'" class="newcomment"><div class="cu"><img src="'+msg.data.avatar+'" /></div><div class="ci"><div class="cc"><a href="http://user.sanwen8.cn/'+msg.data.uid+'/">'+msg.data.username+'</a>：'+msg.data.message+'</div><div class="cd"><a href="javascript:void(0)" onclick="delcomment('+msg.data.cid+');">删除</a>刚刚</div></div></li>').slideDown('slow');
			}
			$.dialog({
				title:'回复结果',
				content:msg.info+'，1s自动关闭！',
				time:1000
			});
		},'json');
	}
});
}